package org.deltaset.desktop;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author dmakariev
 */
abstract class PermissionUtil {

    private PermissionUtil() {
    }

    static List<MenuGroup> filterMenuGroup(List<MenuGroup> src, PermissionFilter filter) {
        final List<MenuGroup> result = new ArrayList<MenuGroup>();
        for (MenuGroup menuGroup : src) {
            if (filter.isAllowed(menuGroup)) {
                result.add(new MenuGroup(menuGroup, filter));
            }
        }
        return result;
    }

    static List<AppItem> filterAppItem(List<AppItem> src, PermissionFilter filter) {
        final List<AppItem> result = new ArrayList<AppItem>();
        for (AppItem appItem : src) {
            if (filter.isAllowed(appItem)) {
                result.add(new AppItem(appItem, filter));
            }
        }
        return result;
    }

    static List<MenuItem> filterMenuItem(List<MenuItem> src, PermissionFilter filter) {
        final List<MenuItem> result = new ArrayList<MenuItem>();
        for (MenuItem menuItem : src) {
            if (filter.isAllowed(menuItem)) {
                result.add(new MenuItem(menuItem));
            }
        }
        return result;
    }
}
